package cn.tj.student.dao.impl;

import cn.tj.student.dao.UserDao;
import cn.tj.student.pojo.User;
import cn.tj.student.util.MybatiesUtil;
import org.apache.ibatis.session.SqlSession;

public class UserDaoImpl implements UserDao {
    @Override
    public int insertUser(User user) {
        SqlSession sqlSession = MybatiesUtil.getSqlSession();
        int row = sqlSession.insert("cn.tj.student.mapper.UserMapper.insertUser", user);
        sqlSession.close();
        return row;
    }
    public User queryByNameAndPassword(User user) {
        SqlSession sqlSession = MybatiesUtil.getSqlSession();
        //selectOne()查询单条数据 表中不能有重复数据 用户账号要唯一
        User u= sqlSession.selectOne("cn.tj.student.mapper.UserMapper.queryByNameAndPassword", user);
        sqlSession.close();
        return u;
    }
}
